
//#include "xsdk_config.h"

#include "watchface.h"
#include "xapp_profile.h"

#include "views.h"

#include "log.h"
#define LOG1    LOG_INFO1

const gui_view_t* watchfacelist[] = 
{
    &viewWatchface1,
    &viewWatchface2,
    &viewWatchface3,  // __MORE_3_COLOCK__
    &viewWatchface4,
//    &viewWatchface5, 
//    &viewWatchface6,
//    &viewWatchface7,
//    &viewWatchface8,
//    &viewWatchface9,
//    &viewWatchface10,
//    &viewWatchface11,
//    &viewWatchface12,
}; 

gui_view_t* views_load_current_watchface(void)
{
    const profile_system_t* p_profile_sys_desc = xapp_profile_get_system();
    
    int idx = p_profile_sys_desc->watchface;
    if( idx >= sizeof(watchfacelist)/sizeof(watchfacelist[0]) )
    {
        idx = 0;
    }
//    GUI_LOG2("watchface index = %d, origin = %x", idx, p_profile_sys_desc->watchface ); 

    return (gui_view_t*)watchfacelist[idx];
}

// load by system configuration 
//const watchface_t* load_watchface(void)
//{
//    return NULL; 
//}
gui_view_t* watchface_load_next(void)
{
    profile_sys_set_watchface_inc();
    const profile_system_t* system = xapp_profile_get_system();
    
    int idx = system->watchface;
    if( idx > PROFILE_LIMIT_WATCHFACE_VALUE_MAX )
    {
        idx = 0;
    }

    return (gui_view_t*)watchfacelist[idx];
}

gui_view_t* watchface_load_prev(void)
{
    profile_sys_set_watchface_dec();
    const profile_system_t* system = xapp_profile_get_system();
    
    int idx = system->watchface;
    if( idx > PROFILE_LIMIT_WATCHFACE_VALUE_MAX )
    {
        idx = 0;
    }

    return (gui_view_t*)watchfacelist[idx];
}


